<template>
  <div class="orderNoRefund">
    <el-form ref="noRefundForm" :model="noRefundModel" :rules="noRefundRules" size="small" label-width="110px">
      <el-form-item label="不退款单号：">
        <el-input v-model="noRefundModel.orderNo" placeholder="请输入不退款单号" readonly disabled clearable :style="{ width: '100%' }" />
      </el-form-item>
      <el-form-item prop="refundReason" label="不退款原因：">
        <el-input v-model="noRefundModel.refundReason" type="textarea" placeholder="请输入不退款原因" :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }" />
      </el-form-item>
      <el-button style="width: 100%;" type="primary" size="small" @click.native="subNoRefund('noRefundForm')">提交</el-button>
    </el-form>
  </div>
</template>

<script>
import { getRefuseRefund as getNewnoRefundFrom } from '@/api/order'

export default {
  name: 'Index',
  props: {
    orderId: {
      type: [String, Number],
      default: 0
    },
    orderNo: {
      type: [String, Number],
      default: 0
    }
  },
  data() {
    return {
      noRefundModel: {
        orderNo: this.orderNo,
        refundReason: ''
      },
      noRefundRules: {
        refundReason: [
          { required: true, message: '请填写不退款原因', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    /**
       * 提交
       */
    subNoRefund(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          getNewnoRefundFrom(this.orderId, {
            refundReason: this.noRefundModel.refundReason
          }).then(() => {
            this.$message.success('提交成功!')
            this.$emit('getNoRefund')
            this.$emit('close')
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
